package com.itheima.service.impl;

import com.itheima.domin.pojo.Dept;
import com.itheima.mapper.DeptMapper;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**部门业务处理
 * @Author:上官徵羽
 * @Date: 2025/07/10 10:41
 * @Description TODO 今日内容:
 */
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    /**查询所有*/
    @Override
    public List<Dept> findAll() {
        //调用持久层
        return deptMapper.findAll();
    }

    /** 删除部门 */
    @Override
    public void delete(Integer id) {
        deptMapper.delete(id);
    }

    /** 添加部门 */
    @Override
    public void add(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    /** 指定查询 */
    @Override
    public Dept selectId(Integer id) {
        return deptMapper.selectId(id);
    }

    /** 修改部门 */
    @Override
    public void updateId(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        dept.setCreateTime(LocalDateTime.now());
        deptMapper.updateId(dept);
    }
}
